package test.baojia.act.business;

import com.alibaba.fastjson.JSONObject;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.testng.Assert;

import java.util.Properties;

public class LogoutBusiness extends Business {

    @Override
    public void run(JSONObject context, WebDriver driver, Properties resource, JSONObject parentContext) throws  Exception {
        super.run(context, driver, resource, parentContext);
        driver.switchTo().defaultContent();
        //退出按钮没有id，所以用xpath。
        driver.findElement(By.xpath("//*[@id=\"banner\"]/div[2]/ul/li[2]/label/a")).click();
        //登录页头部没有id，所以用xpath。
        By loginDivBy = By.xpath("/html/body/div[1]");
        String loginDivByClass = this.newWebDriverWait(null)
                .until(ExpectedConditions.presenceOfElementLocated(loginDivBy)
                ).getAttribute("class");
        Assert.assertEquals(loginDivByClass , "logintop");
    }
}
